<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>NodeMCU-MicroPython配置实录 | Mox的笔记库</title><meta name="keywords" content="Working"><meta name="author" content="MocusEZ"><meta name="copyright" content="MocusEZ"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="NodeMCU-MicroPython配置实录">
<meta property="og:type" content="article">
<meta property="og:title" content="NodeMCU-MicroPython配置实录">
<meta property="og:url" content="https://www.mocusez.site/posts/c18a.html">
<meta property="og:site_name" content="Mox的笔记库">
<meta property="og:description" content="NodeMCU-MicroPython配置实录">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://pic3.zhimg.com/v2-8c8b9fa56cef3c07e5fbf09c49127062_1440w.jpg">
<meta property="article:published_time" content="2022-01-20T11:22:00.000Z">
<meta property="article:modified_time" content="2022-05-04T13:00:00.000Z">
<meta property="article:author" content="MocusEZ">
<meta property="article:tag" content="Working">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic3.zhimg.com/v2-8c8b9fa56cef3c07e5fbf09c49127062_1440w.jpg"><link rel="shortcut icon" href="/img/title.jpg"><link rel="canonical" href="https://www.mocusez.site/posts/c18a"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?c85c9eaebc158345532b86397a6dded9";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'NodeMCU-MicroPython配置实录',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-04 21:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/atom.xml" title="Mox的笔记库" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/head.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链&amp;私人收藏</span></a></div><div class="menus_item"><a class="site-page" href="/board/"><i class="fa-fw fas fa-user"></i><span> 留言板</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://pic3.zhimg.com/v2-8c8b9fa56cef3c07e5fbf09c49127062_1440w.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Mox的笔记库</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链&amp;私人收藏</span></a></div><div class="menus_item"><a class="site-page" href="/board/"><i class="fa-fw fas fa-user"></i><span> 留言板</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">NodeMCU-MicroPython配置实录</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-01-20T11:22:00.000Z" title="发表于 2022-01-20 19:22:00">2022-01-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-04T13:00:00.000Z" title="更新于 2022-05-04 21:00:00">2022-05-04</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%97%A5%E5%B8%B8%E7%AC%94%E8%AE%B0/">日常笔记</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="NodeMCU-MicroPython配置实录"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="NodeMCU-MicroPython配置实录"><a href="#NodeMCU-MicroPython配置实录" class="headerlink" title="NodeMCU-MicroPython配置实录"></a>NodeMCU-MicroPython配置实录</h1><p>发现网络上的记录过于混杂，自己写一下笔记防止到时找不到资料</p>
<p>不会Python？百度搜索“菜鸟教程”，看看Python3就会了，人生苦短，我选Python</p>
<h2 id="刷MicroPython包"><a href="#刷MicroPython包" class="headerlink" title="刷MicroPython包"></a>刷MicroPython包</h2><p>去micropython的官网下载，选择正常版本（2Mib+）下载即可</p>
<p><img src="https://ae04.alicdn.com/kf/H5614735f136243e592fc7171a6d19862V.png" alt="image.png"></p>
<p><strong>（此处默认已经装完Python，并默认加入path，如果未安装自行百度）</strong></p>
<p>下载完以后，本地的pip使用这个指令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install esptool</span><br></pre></td></tr></table></figure>

<p>找到设备所在的端口</p>
<p>控制面板-&gt;硬件和声音-&gt;设备管理器</p>
<p><img src="https://ae05.alicdn.com/kf/Hf32290ed10d8422aa55c1aca08f15c25L.png" alt="image.png"></p>
<p>得知我们的设备运行在COM3</p>
<p><img src="https://ae02.alicdn.com/kf/He9b2e7662f03430cbf1e72f27875cf21x.png" alt="image-20220120190147742.png"></p>
<p>在esp8266-20220117-v1.18.bin所在的目录，打开cmd输入以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">esptool.py --port COM3 erase_flash</span><br><span class="line">esptool.py --port COM3 --baud 460800 write_flash --flash_size=detect 0 esp8266-20220117-v1.18.bin --verify</span><br></pre></td></tr></table></figure>

<p>等待烧写成功</p>
<h3 id="Thonny版本"><a href="#Thonny版本" class="headerlink" title="Thonny版本"></a>Thonny版本</h3><p>纯傻瓜教学版+免安装esptool版</p>
<p><strong>默认Thonny装在C盘默认目录</strong></p>
<p>意外发现Thonny自带esptool，省掉安装麻烦</p>
<p>从这里进入shell</p>
<p><img src="https://ae05.alicdn.com/kf/H9ef5991a1dc64673a9023d5d117634a22.png" alt="image.png"></p>
<p>找到插件的安装位置</p>
<p>输入指令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd C:\Users\Administrator\AppData\Local\Programs\Thonny\Lib\site-packages</span><br><span class="line">python esptool.py</span><br></pre></td></tr></table></figure>

<p>就会显示这样的界面</p>
<p><img src="https://ae05.alicdn.com/kf/H32157491a46545fd888e220c6018f2a3c.png" alt="image-20220120185850811.png"></p>
<p>效仿上面</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">python esptool.py --port COM3 erase_flash</span><br><span class="line">python esptool.py --port COM3 --baud 460800 write_flash --flash_size=detect 0 esp8266-20220117-v1.18.bin --verify</span><br></pre></td></tr></table></figure>

<p><img src="https://ae05.alicdn.com/kf/H9b96bd37e6a84fb1b687f01d288dfaabV.png" alt="image-20220120190550557.png"></p>
<p>等待烧写完成，下图为烧写完成的图像</p>
<p><img src="https://ae01.alicdn.com/kf/Hcc15ceb3fe124598916c81fe6635eb20k.png" alt="image-20220120190704552.png"></p>
<h2 id="IDE配置"><a href="#IDE配置" class="headerlink" title="IDE配置"></a>IDE配置</h2><p>我个人喜欢Pycharm，但Thonny不需要装插件，简单轻巧，推荐这个</p>
<p>（怎么能没有万能的VScode呢？问就是插件配置有问题）</p>
<p>打开运行-&gt;设置解释器</p>
<p><img src="https://ae01.alicdn.com/kf/Hea73cb45f12b40c59ffac824c01e55e2m.png" alt="image.png"></p>
<p>配置正常应当是这种情况</p>
<p><img src="https://ae02.alicdn.com/kf/H5c09c644a03b49f1bec2aabf2a253a27d.png" alt="image.png"></p>
<p>顺利运行</p>
<p>跑个指令看看</p>
<p><img src="https://ae02.alicdn.com/kf/H7e8820b6e0424efd8e47af3b1b30bcb1m.png" alt="image.png"></p>
<h2 id="上传文件"><a href="#上传文件" class="headerlink" title="上传文件"></a>上传文件</h2><p>打开</p>
<p><img src="https://ae05.alicdn.com/kf/H9f55e9c7ac504bcbacfc0b7fde002256e.png" alt="image-20220120191437877.png"></p>
<p>选择MicroPython设备，默认只有boot.py</p>
<p><img src="https://ae03.alicdn.com/kf/Hc49dfb7fe6644d96bea2712b8b28690ci.png" alt="image.png"></p>
<p>文件命名为main.py的话，NodeMCU开机就会运行main.py</p>
<p>重要的事情说三遍</p>
<p><strong>不允许写死循环程序！死循环程序拔掉线后板子无法刷入任何程序</strong>！！</p>
<p><strong>不允许写死循环程序！死循环程序拔掉线后板子无法刷入任何程序</strong>！！</p>
<p><strong>不允许写死循环程序！死循环程序拔掉线后板子无法刷入任何程序</strong>！！</p>
<p>2022.2.26更新：找到解决方案了，连上thonny后，对着shell窗口狂按Ctrl+C就有概率使板子停止运行，板子停下来后，移除main.py或者输入其他非micropython固件即可摆脱循环</p>
<h2 id="好用的库"><a href="#好用的库" class="headerlink" title="好用的库"></a>好用的库</h2><h3 id="ujson"><a href="#ujson" class="headerlink" title="ujson"></a>ujson</h3><p><a target="_blank" rel="noopener external nofollow noreferrer" href="http://micropython.circuitpython.com.cn/en/latet/library/ujson.html">http://micropython.circuitpython.com.cn/en/latet/library/ujson.html</a></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">import json</span><br><span class="line">a=&#123;&#x27;12&#x27;:&#x27;dd&#x27;,&#x27;13&#x27;:&#x27;ee&#x27;&#125;</span><br><span class="line">d=json.dumps(a)</span><br><span class="line">print(d)</span><br></pre></td></tr></table></figure>





<h3 id="urequests"><a href="#urequests" class="headerlink" title="urequests"></a>urequests</h3><p>发送网络请求</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">import urequests</span><br><span class="line">response = urequests.get(&#x27;http://jsonplaceholder.typicode.com/albums/1&#x27;)</span><br><span class="line">print(response.text)</span><br><span class="line">print(response.status_code)</span><br></pre></td></tr></table></figure>









<h2 id="定时器"><a href="#定时器" class="headerlink" title="定时器"></a>定时器</h2><p>定时器相比较于延时函数，不占用CPU运行时间</p>
<h3 id="timer-deinit"><a href="#timer-deinit" class="headerlink" title="timer.deinit()"></a>timer.deinit()</h3><p>解除定时器的功能</p>
<h2 id="驱动屏幕-I2C"><a href="#驱动屏幕-I2C" class="headerlink" title="驱动屏幕(I2C)"></a>驱动屏幕(I2C)</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> machine <span class="keyword">import</span> Pin,I2C,RTC</span><br><span class="line"><span class="keyword">from</span> ssd1306 <span class="keyword">import</span> SSD1306_I2C</span><br><span class="line">i2c = I2C(scl=Pin(<span class="number">5</span>), sda=Pin(<span class="number">4</span>))</span><br><span class="line">oled = SSD1306_I2C(<span class="number">128</span>, <span class="number">64</span>, i2c)</span><br><span class="line">oled.fill(<span class="number">0</span>)</span><br><span class="line">oled.show()</span><br><span class="line">oled.text(<span class="string">&quot;Hello World！&quot;</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">oled.text(<span class="string">&quot;Welcome&quot;</span>,<span class="number">0</span>,<span class="number">16</span>)  <span class="comment">#第二行</span></span><br><span class="line">oled.show()</span><br></pre></td></tr></table></figure>

<p>注意</p>
<p>屏幕是128<em>64分辨率，就是横向(X轴)有128个像素点，纵向(Y轴)有64个点，一共是128</em>64&#x3D;8192个像素点。我们点亮需要的像素点，就能成像出我们需要的图像</p>
<p>具体还得看手册</p>
<p><img src="https://ae05.alicdn.com/kf/H76c7dbf7e4c646c585a9b35b0792892d6.png" alt="V)9Y7$%(12L9~77SODR8LXF.jpg"></p>
<p>硬件管脚图：</p>
<p><img src="https://ae01.alicdn.com/kf/H3364c72b863c4664834edf909c34ed7eQ.png" alt="4268f878dcb8a03ecdc14346a1cc4857.jpg"></p>
<p>全引脚展示</p>
<p><img src="https://ae05.alicdn.com/kf/Hcf7af451a7f24dfdb395e5f8badcbf7aW.png" alt="image-20210205161507654.png"></p>
<p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://blog.csdn.net/weixin_34808718/article/details/112106155">esp8266手册_ESP8266用Micropython点亮I2C接口Oled</a></p>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p><a target="_blank" rel="noopener external nofollow noreferrer" href="http://docs.micropython.org/en/latest/library/index.htm">http://docs.micropython.org/en/latest/library/index.htm</a></p>
<p>官方资料</p>
<p><a target="_blank" rel="noopener external nofollow noreferrer" href="http://micropython.circuitpython.com.cn/en/latet/library/index.html">http://micropython.circuitpython.com.cn/en/latet/library/index.html</a></p>
<p>中文翻译资料</p>
<p>编译mpy字节码</p>
<p> <a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.cnblogs.com/yafengabc/p/8682910.html">https://www.cnblogs.com/yafengabc/p/8682910.html</a></p>
<p>ESP32有关蓝牙广播的案例</p>
<p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_advertising.py">https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_advertising.py</a></p>
<h2 id="Webrpl"><a href="#Webrpl" class="headerlink" title="Webrpl"></a>Webrpl</h2><p>要连接wifi的话，需要把wifi名称和写进boot.py里面，main.py不行</p>
<h2 id="记录一个诡异事件"><a href="#记录一个诡异事件" class="headerlink" title="记录一个诡异事件"></a>记录一个诡异事件</h2><p>全局变量要放在最前面</p>
<p>函数的位置不能随意挪动</p>
<p>明明python没有函数重载，那为什么这个文件能运行？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> tftlcd <span class="keyword">import</span> LCD32</span><br><span class="line"><span class="keyword">from</span> touch <span class="keyword">import</span> XPT2046</span><br><span class="line"><span class="keyword">import</span> time,gui,random</span><br><span class="line"><span class="keyword">from</span> machine <span class="keyword">import</span> Timer,Pin</span><br><span class="line"><span class="keyword">from</span> test_mqtt <span class="keyword">import</span> WIFI_Connect</span><br><span class="line"><span class="keyword">from</span> json <span class="keyword">import</span> dumps</span><br><span class="line"><span class="keyword">from</span> simple <span class="keyword">import</span> MQTTClient <span class="comment">#导入MQTT板块</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#定义常用颜色</span></span><br><span class="line">RED = (<span class="number">255</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">GREEN = (<span class="number">0</span>,<span class="number">255</span>,<span class="number">0</span>)</span><br><span class="line">BLUE = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">255</span>)</span><br><span class="line">BLACK = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">WHITE = (<span class="number">255</span>,<span class="number">255</span>,<span class="number">255</span>)</span><br><span class="line"></span><br><span class="line">d = LCD32(portrait=<span class="number">1</span>) <span class="comment">#默认方向竖屏</span></span><br><span class="line">t = XPT2046()<span class="comment">#默认方向</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#填充白色</span></span><br><span class="line">d.fill(WHITE)</span><br><span class="line"></span><br><span class="line"><span class="comment">#MQTT配置</span></span><br><span class="line">SERVER = <span class="string">&#x27;&#x27;</span></span><br><span class="line">USERNAME = <span class="string">&#x27;&#x27;</span></span><br><span class="line">PASSWORD = <span class="string">&#x27;&#x27;</span></span><br><span class="line">PORT = <span class="number">1883</span></span><br><span class="line">CLIENT_ID = <span class="string">&#x27;&#x27;</span> <span class="comment"># 客户端ID</span></span><br><span class="line">TOPIC = <span class="string">&#x27;T87HBZV2AE/ESP32Board/event&#x27;</span> <span class="comment"># TOPIC名称</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># MQTTsend函数(&quot;Bug&quot;)</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">MQTT_Send</span>(<span class="params">list2</span>):</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;hello&quot;</span>)</span><br><span class="line">    </span><br><span class="line"><span class="comment">#屏幕刷新</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">flash</span>(<span class="params">list2</span>):</span><br><span class="line">    d.printStr(<span class="built_in">str</span>(list2[<span class="number">0</span>][<span class="string">&#x27;x&#x27;</span>])+<span class="string">&quot;,&quot;</span>+<span class="built_in">str</span>(list2[<span class="number">0</span>][<span class="string">&#x27;y&#x27;</span>]), <span class="number">90</span>, <span class="number">78</span>, RED, size=<span class="number">2</span>)</span><br><span class="line">    d.printStr(<span class="built_in">str</span>(list2[<span class="number">1</span>]), <span class="number">90</span>, <span class="number">123</span>, RED, size=<span class="number">2</span>)</span><br><span class="line">    d.printStr(<span class="built_in">str</span>(list2[<span class="number">2</span>]), <span class="number">90</span>, <span class="number">168</span>, RED, size=<span class="number">2</span>)</span><br><span class="line">    d.printStr(<span class="built_in">str</span>(list2[<span class="number">3</span>]), <span class="number">90</span>, <span class="number">213</span>, RED, size=<span class="number">2</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">#按钮</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">fun1</span>(<span class="params">B1</span>):</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;hello&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">fun2</span>(<span class="params">B1</span>):</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;hello 2&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># #############################</span></span><br><span class="line"><span class="comment"># #### 定时器用于扫描按钮触发事件 ##</span></span><br><span class="line"><span class="comment">#############################</span></span><br><span class="line">tim_flag = <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">count</span>(<span class="params">tim</span>):</span><br><span class="line">    <span class="keyword">global</span> tim_flag</span><br><span class="line">    tim_flag = <span class="number">1</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">ll</span>(<span class="params">tim</span>):</span><br><span class="line">    c=&#123;<span class="string">&#x27;x&#x27;</span>: <span class="built_in">round</span>(-<span class="number">3</span> + random.random() * <span class="number">6</span>,<span class="number">2</span>),<span class="string">&#x27;y&#x27;</span>: <span class="built_in">round</span>(-<span class="number">3</span> + random.random() * <span class="number">6</span>,<span class="number">2</span>)&#125;</span><br><span class="line">    list2=[c,<span class="number">37</span>,<span class="built_in">round</span>(random.random()*<span class="number">100</span>,<span class="number">2</span>),<span class="number">50</span> + <span class="built_in">round</span>(random.random() * <span class="number">40</span>,<span class="number">2</span>),time.mktime(time.localtime())]</span><br><span class="line">    flash(list2)</span><br><span class="line">    MQTT_Send(list2)</span><br><span class="line">    </span><br><span class="line"><span class="comment"># MQTTsend函数(&quot;True&quot;)</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">MQTT_Send</span>(<span class="params">list2</span>):</span><br><span class="line">    list1=[<span class="string">&quot;coordinate&quot;</span>,<span class="string">&quot;temperature&quot;</span>,<span class="string">&quot;blood_oxygen&quot;</span>,<span class="string">&quot;heart_rate&quot;</span>,<span class="string">&quot;timestamp&quot;</span>]</span><br><span class="line">    b=<span class="built_in">zip</span>(list1,list2)</span><br><span class="line">    msg1=dumps(<span class="built_in">dict</span>(b))</span><br><span class="line">    <span class="built_in">print</span>(msg1)</span><br><span class="line">    client.publish(TOPIC, msg1,qos=<span class="number">1</span>)</span><br><span class="line">    </span><br><span class="line"><span class="comment">#主函数+定时器</span></span><br><span class="line"><span class="keyword">if</span> WIFI_Connect():</span><br><span class="line">    client = MQTTClient(CLIENT_ID, SERVER, PORT,USERNAME,PASSWORD,<span class="number">60</span>)</span><br><span class="line">    client.connect()</span><br><span class="line">    d.Picture(<span class="number">0</span>,<span class="number">0</span>,<span class="string">&quot;all.jpg&quot;</span>)</span><br><span class="line">    B1 = gui.TouchButton(<span class="number">40</span>,<span class="number">250</span>,<span class="number">80</span>,<span class="number">50</span>,BLUE,<span class="string">&#x27;On&#x27;</span>,WHITE,fun1)</span><br><span class="line">    B2 = gui.TouchButton(<span class="number">140</span>,<span class="number">250</span>,<span class="number">80</span>,<span class="number">50</span>,RED,<span class="string">&#x27;Off&#x27;</span>,WHITE,fun2)</span><br><span class="line">    </span><br><span class="line">    data = Timer(-<span class="number">1</span>)</span><br><span class="line">    data.init(period=<span class="number">1000</span>, mode=Timer.PERIODIC,callback=ll)</span><br><span class="line">    </span><br><span class="line">    <span class="comment">#构建软件定时器，编号1</span></span><br><span class="line">    tim = Timer(<span class="number">1</span>) </span><br><span class="line">    tim.init(period=<span class="number">20</span>, mode=Timer.PERIODIC,callback=count) <span class="comment">#周期为20ms</span></span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>: </span><br><span class="line">        <span class="comment">#执行按钮触发的任务</span></span><br><span class="line">        <span class="keyword">if</span> tim_flag == <span class="number">1</span>:</span><br><span class="line">            t.tick_inc()</span><br><span class="line">            gui.task_handler()</span><br><span class="line">            tim_flag = <span class="number">0</span></span><br></pre></td></tr></table></figure>

<p>就问，哪个MQTT_Send会被运行？</p>
<p>最终解决方案：把提供mqtt功能的python文件通过mpy_cross编译成字节码以后放到板子上，再也没有出现过这样的问题</p>
<h2 id="踩坑"><a href="#踩坑" class="headerlink" title="踩坑"></a>踩坑</h2><p>esp8266没有radint和random.choice()</p>
<p>只有<code>random.``getrandbits</code><strong>(<em><strong>size</strong></em>)</strong></p>
<p>还有个<code>random.``seed</code>**(*用于生成种子</p>
<p>5月4日把ESP8266的GPIO3给干坏了，花了三到四个小时才检测出来</p>
<p>感觉IIC的控制有问题，也有可能是MAX30205的锅</p>
<h2 id="MAX30102使用"><a href="#MAX30102使用" class="headerlink" title="MAX30102使用"></a>MAX30102使用</h2></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://www.mocusez.site">MocusEZ</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://www.mocusez.site/posts/c18a.html">https://www.mocusez.site/posts/c18a.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc/4.0" rel="external nofollow noreferrer" target="_blank">CC BY-NC 4.0</a> 许可协议。转载请注明来自 <a href="https://www.mocusez.site" target="_blank">Mox的笔记库</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://pic3.zhimg.com/v2-8c8b9fa56cef3c07e5fbf09c49127062_1440w.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/61f6.html"><img class="prev-cover" src="https://pic1.zhimg.com/v2-137105887817f87ee3f6939434fa5a2d_r.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Frida hook初次实战</div></div></a></div><div class="next-post pull-right"><a href="/posts/8a62.html"><img class="next-cover" src="https://pic1.zhimg.com/v2-bd843f42914ff75f88b484341ce35e2d_1440w.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Log4j2漏洞复现</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="waline-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/head.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">MocusEZ</div><div class="author-info__description">探索未曾设想的道路</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/mocusez" rel="external nofollow noreferrer" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:285918468@qq.com" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title="RSS"><i class="fas fa-rss"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">迎接新的明天</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#NodeMCU-MicroPython%E9%85%8D%E7%BD%AE%E5%AE%9E%E5%BD%95"><span class="toc-number">1.</span> <span class="toc-text">NodeMCU-MicroPython配置实录</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%B7MicroPython%E5%8C%85"><span class="toc-number">1.1.</span> <span class="toc-text">刷MicroPython包</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Thonny%E7%89%88%E6%9C%AC"><span class="toc-number">1.1.1.</span> <span class="toc-text">Thonny版本</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#IDE%E9%85%8D%E7%BD%AE"><span class="toc-number">1.2.</span> <span class="toc-text">IDE配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6"><span class="toc-number">1.3.</span> <span class="toc-text">上传文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A5%BD%E7%94%A8%E7%9A%84%E5%BA%93"><span class="toc-number">1.4.</span> <span class="toc-text">好用的库</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#ujson"><span class="toc-number">1.4.1.</span> <span class="toc-text">ujson</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#urequests"><span class="toc-number">1.4.2.</span> <span class="toc-text">urequests</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9A%E6%97%B6%E5%99%A8"><span class="toc-number">1.5.</span> <span class="toc-text">定时器</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#timer-deinit"><span class="toc-number">1.5.1.</span> <span class="toc-text">timer.deinit()</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A9%B1%E5%8A%A8%E5%B1%8F%E5%B9%95-I2C"><span class="toc-number">1.6.</span> <span class="toc-text">驱动屏幕(I2C)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="toc-number">1.7.</span> <span class="toc-text">参考资料</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Webrpl"><span class="toc-number">1.8.</span> <span class="toc-text">Webrpl</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%B0%E5%BD%95%E4%B8%80%E4%B8%AA%E8%AF%A1%E5%BC%82%E4%BA%8B%E4%BB%B6"><span class="toc-number">1.9.</span> <span class="toc-text">记录一个诡异事件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B8%A9%E5%9D%91"><span class="toc-number">1.10.</span> <span class="toc-text">踩坑</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#MAX30102%E4%BD%BF%E7%94%A8"><span class="toc-number">1.11.</span> <span class="toc-text">MAX30102使用</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/3e9f.html" title="RMM观察与初探"><img src="https://z1.ax1x.com/2023/10/21/piF47TA.md.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="RMM观察与初探"/></a><div class="content"><a class="title" href="/posts/3e9f.html" title="RMM观察与初探">RMM观察与初探</a><time datetime="2023-10-21T04:30:00.000Z" title="发表于 2023-10-21 12:30:00">2023-10-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5e44.html" title="计算机网络课设——UDP/TCP/TLS Socket实验"><img src="https://s1.ax1x.com/2023/09/09/pP6qXOU.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="计算机网络课设——UDP/TCP/TLS Socket实验"/></a><div class="content"><a class="title" href="/posts/5e44.html" title="计算机网络课设——UDP/TCP/TLS Socket实验">计算机网络课设——UDP/TCP/TLS Socket实验</a><time datetime="2023-09-09T07:10:00.000Z" title="发表于 2023-09-09 15:10:00">2023-09-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/cd44.html" title="JQuery的XSS初探"><img src="https://s1.ax1x.com/2023/09/08/pPyvO0O.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JQuery的XSS初探"/></a><div class="content"><a class="title" href="/posts/cd44.html" title="JQuery的XSS初探">JQuery的XSS初探</a><time datetime="2023-09-08T04:30:00.000Z" title="发表于 2023-09-08 12:30:00">2023-09-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5862.html" title="生产实习记录"><img src="https://s1.ax1x.com/2023/09/02/pPBH058.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="生产实习记录"/></a><div class="content"><a class="title" href="/posts/5862.html" title="生产实习记录">生产实习记录</a><time datetime="2023-09-02T13:51:00.000Z" title="发表于 2023-09-02 21:51:00">2023-09-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/9a9b.html" title="Fedora-CoreOS配置与试用（2023年）"><img src="https://s1.ax1x.com/2023/08/28/pPa8tlF.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Fedora-CoreOS配置与试用（2023年）"/></a><div class="content"><a class="title" href="/posts/9a9b.html" title="Fedora-CoreOS配置与试用（2023年）">Fedora-CoreOS配置与试用（2023年）</a><time datetime="2023-08-28T11:35:00.000Z" title="发表于 2023-08-28 19:35:00">2023-08-28</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2023 By MocusEZ</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a href="http://beian.miit.gov.cn/" rel="external nofollow noreferrer"  style="color:#f72b07" target="_blank">闽ICP备2021003009号</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadWaline () {
  function insertCSS () {
    const link = document.createElement("link")
    link.rel = "stylesheet"
    link.href = "https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.min.css"
    document.head.appendChild(link)
  }

  function initWaline () {
    const waline = Waline.init(Object.assign({
      el: '#waline-wrap',
      serverURL: 'https://waline.mocusez.site',
      pageview: ,
      dark: 'html[data-theme="dark"]',
      path: window.location.pathname,
      comment: false,
    }, null))
  }

  if (typeof Waline === 'function') initWaline()
  else {
    insertCSS()
    getScript('https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.min.js').then(initWaline)
  }
}

if ('Waline' === 'Waline' || !false) {
  if (false) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
  else setTimeout(loadWaline, 0)
} else {
  function loadOtherComment () {
    loadWaline()
  }
}</script></div><script>(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/1df8ba05.js","daovoice")
</script><script>var isChatBtn = false
daovoice('init', {
  app_id: '1df8ba05',},{
  launcher: { 
     disableLauncherIcon: isChatBtn // 悬浮 ICON 是否显示
  },
});
daovoice('update');

if (isChatBtn) {
  var chatBtnFn = () => {
    var chatBtn = document.getElementById("chat_btn")
    chatBtn.addEventListener("click", function(){
      daovoice('show')
    });
  }
  chatBtnFn()
} else {
  if (false) {
    function chatBtnHide () {
      daovoice('update', {},{
        launcher: { 
        disableLauncherIcon: true // 悬浮 ICON 是否显示
        },
      });
    }
    function chatBtnShow () {
      daovoice('update', {},{
        launcher: { 
        disableLauncherIcon: false // 悬浮 ICON 是否显示
        },
      });
    }
  }
}</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>